Next | Prev | Up | Top | Contents | Index

Creating Device Files With mknod

You may need to create specific device files that are not created by MAKEDEV; for example, a device file for a partition that is not created by default. You can edit /dev/MAKEDEV or files in /dev/MAKEDEV.d as described in the section "Creating Device Files With MAKEDEV" in this chapter or use the mknod command to create a specific device special file in /dev.

The three forms of the mknod command are:

mknod  name b major minor 
mknod  name c major minor 
mknod  name p 
The arguments of mknod are:

name

Specifies the name of the special file.

b

Specifies a block device.

c

Specifies a character device.

major

major specifies a device type that corresponds to an appropriate entry in the block or character device switch tables.

minor

The minor number indicates a unit of the device. It distinguishes peripheral devices from each other.

p

Specifies the special file as a first-in, first-out (FIFO) device. This is also known as a named pipe. Named pipes have nothing to do with disks; the use of this option is not described in this guide.
As an example, create a character (raw) device file for partition 3 of a SCSI disk that is on controller 0 at drive address 2 (partition 3 has been created by custom partitioning of the disk with fx). The value of name would be /dev/rdsk/dks0d2s3:

/dev/

All device files are in this directory.

rdsk/

The directory for character (raw) device files for disks.

dks

It is a SCSI disk.

0d2s3

Controller 0, drive address 2, partition 3.
To determine the values of major and minor, start by listing the contents of the device file directory for this disk:

# ls -l /dev/rdsk/dks0d2* 
crw-------    1 root     sys      128, 32 Nov 30 06:49 dks0d2s0
crw-------    1 root     sys      128, 33 Nov 30 06:49 dks0d2s1
crw-------    1 root     sys      128, 38 Nov 30 06:49 dks0d2s6
crw-------    1 root     sys      128, 39 Nov 30 06:49 dks0d2s7
crw-------    1 root     sys      128, 40 Nov 30 06:49 dks0d2vh
crw-------    1 root     sys      128, 42 Nov 30 06:49 dks0d2vol
The major device number for this disk is 128. Looking at the minor numbers, you can see that they are assigned based on the partition number. Partition 3 should be minor number 35.

The command to make a device file for the character device for this partition is:

# mknod /dev/rdsk/dks0d2s2 c 128 35 


Next | Prev | Up | Top | Contents | Index